#!/sbin/openrc-run

piddir=/var/run/quagga
pidfile=$piddir/$SVCNAME.pid
command=/usr/sbin/$SVCNAME
command_args="-d -f /etc/quagga/$SVCNAME.conf --pid_file $pidfile"

depend() {
	need net
	after firewall opennhrp
}

cleanup() {
	ebegin "Cleaning up stale zebra routes"
	ip route flush proto zebra
	eend $?
}

checkconfig() {
	if ! [ -e /etc/quagga/$SVCNAME.conf ] ; then
		eerror "You need to create /etc/quagga/$SVCNAME.conf first."
		eerror "An example can be found in /usr/share/doc/quagga/$SVCNAME.conf.sample"
		eerror "from quagga-doc package"
		return 1
	fi
	return 0
}

start_pre() {
	checkconfig || return 1
	checkpath --owner quagga:quagga --directory $piddir
	cleanup
}

